/*
 * Copyright (c) 2021 Zsj. All rights reserved.
 */

package com.jzz.crawlerweb.handler.generator.impl;

import com.jzz.crawlerweb.handler.generator.ImageHandler;
import com.jzz.crawlerweb.handler.generator.WaveEffect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.awt.image.BufferedImage;
import java.util.Random;

/**
 * 生成扭曲图像
 */
public class TwistImageHandler implements ImageHandler {
    private static final Logger logger = LoggerFactory.getLogger(TwistImageHandler.class);

    private final Random random = new Random();

    @Override
    public BufferedImage handle(BufferedImage bi, Object... args) {
        int span = random.nextInt(5) + 30;
        int peak = random.nextInt(4) + 6;
        int beta = 30;
        int offset = random.nextInt(4) + 31;
        return WaveEffect.rippleImage(WaveEffect.waveImage(bi, span, peak, beta, offset), 1, peak, offset);
    }

}
